#include<bits/stdc++.h>
using namespace std;
int a[200001],n,ans,dp[101][101][101];
void dfs(int dep,int last_blue,int last_red,int sum)
{
    if(dp[dep][last_blue][last_red]>sum)return ;
    dp[dep][last_blue][last_red]=sum;
    if(dep>n)
    {
        ans=max(ans,sum);
        return ;
    }
    if(a[dep]==last_blue)dfs(dep+1,a[dep],last_red,sum+a[dep]);
    else dfs(dep+1,a[dep],last_red,sum);
    if(a[dep]==last_red)dfs(dep+1,last_blue,a[dep],sum+a[dep]);
    else dfs(dep+1,last_blue,a[dep],sum);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        ans=0;
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i];
        dfs(1,0,0,0);
        cout<<ans<<"\n";
    }
}
